#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
	
	cout << "---setup()---" << endl;
	
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	
	//head
    head.setup();
	head.setPosition(200, 100);
	head.setMovePixels(3);
	head.setSize(50);

	
	//
	arduino.setup(5, 9600);
	ofAddListener(arduino.onJoystickMoved, this, &ofApp::onJoystickMoved );
}

//--------------------------------------------------------------
void ofApp::update(){
    head.update();
	arduino.update();
}

//--------------------------------------------------------------
void ofApp::draw(){
    head.draw();
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    head.keyPressed(key);
	
}

//--------------------------------------------------------------
void ofApp::onJoystickMoved(EventArgsJoystick & args) {
	
	cout << "---onJoystickMoved Event---" << endl;
	cout << args.joystickNum << endl;
	cout << args.joystickPinNum << endl;
	cout << args.joystickStatus << endl;
	
	//pass on to head movement..
	
	//head[joystickNum].setDirection( headController::DIRECTION_RIGHT );
	
}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

